

export default {
    getCookie (name) {
        var strcookie = document.cookie;//获取cookie字符串
        var arrcookie = strcookie.split("; ");//分割
        //遍历匹配
        for ( var i = 0; i < arrcookie.length; i++) {
            var arr = arrcookie[i].split("=");
            if (arr[0] == name){
                return arr[1];
            }
        }
        return "";
    },
    setCookie (name,value) {
		var Days = 30;
		var exp = new Date();
		exp.setTime(exp.getTime() + Days*24*60*60*30);
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
    },
    getUserInfo () {
        try {
            // if(localStorage.userInfo) {
                // return JSON.parse(localStorage.userInfo)
                return {
                    subscribe:1,
                    openid:'oXZV00usRzJ2o6r45j3ApCkOVrok',
                    nickname:"Rong@Sheng",
                    sex:1,
                    language:"zh_CN",
                    city:"江门",
                    province:"广东",
                    country:"中国",
                    headimgurl:"http://thirdwx.qlogo.cn/mmopen/ZiaUBz1LfJQEvAz5aibovgibggsDB6vrRsJeic5pS4ILv5L7eImiauLeIrCibSDVesj6tWvFkO9fVkibcOkfnhFric9HnXGPtaKdkIl8/132",
                    subscribe_time:1534472603,
                    remark:"",
                    groupid:0,
                    tagid_list:[],
                    subscribe_scene:"ADD_SCENE_SEARCH",
                    qr_scene:0,
                    qr_scene_str:"",
                    lastLoginTime: new Date().getTime(),
                    userid:"100000"
                }
            // } else{
            //     return null
            // }
        } catch(e) {

        }
    },
    setUserInfo (data) {
        localStorage.userInfo = JSON.stringify(data)
    },
    clearUserInfo() {
        localStorage.userInfo = null
    },
    formatDateTime (timeStamp) { 
        var date = new Date()
        date.setTime(timeStamp * 1000)
        var y = date.getFullYear()    
        var m = date.getMonth() + 1    
        m = m < 10 ? ('0' + m) : m    
        var d = date.getDate()    
        d = d < 10 ? ('0' + d) : d    
        var h = date.getHours()  
        h = h < 10 ? ('0' + h) : h  
        var minute = date.getMinutes()  
        var second = date.getSeconds()  
        minute = minute < 10 ? ('0' + minute) : minute    
        second = second < 10 ? ('0' + second) : second   
        return m + '-' + d+' '+h+':'+minute   
        // return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;    
    }
}